package com.solute.utils.services.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import com.solute.domain.SolutionVO;

@Component
public interface SolutionDao {
	@Select({
		"SELECT id, \n",
		"       problem, \n",
		"       solution, \n",
		"       source, \n",
		"       answer, \n",
		"       problem_img_gid as problemImageGid, \n",
		"       solution_img_gid as solutionImageGid, \n",
		"       tag_gid \n",
		"  FROM solutions WHERE id = #{id} \n",
		" \n"
	})
	public <T> SolutionVO selectSolutionById(T id);

	@Insert({
		"insert into solutions ( \n",
		"   id \n",
		"  ,problem \n",
		"  ,solution \n",
		"  ,source \n",
		"  ,answer \n",
		"  ,problem_img_gid \n",
		"  ,solution_img_gid \n",
		"  ,tag_gid \n",
		") VALUES ( \n",
		"   #{id}  -- id - IN varchar(36)  \n",
		"  ,#{problem}  -- problem - IN varchar(4000) \n",
		"  ,#{solution}  -- solution - IN varchar(4000) \n",
		"  ,#{source}  -- source - IN varchar(256) \n",
		"  ,#{answer}  -- answer - IN varchar(256) \n",
		"  ,#{problemImageGid}  -- problem_img_gid - IN varchar(36) \n",
		"  ,#{solutionImageGid}  -- solution_img_gid - IN varchar(36) \n",
		"  ,#{tagGid}  -- tag_gid - IN varchar(36) \n",
		") \n"
	})
	public <T> void insertSolution(T param);
	
	@Delete({
		"DELETE FROM solutions \n",
		" WHERE id = #{id} -- varchar(36) \n"
	})
	public <T> void deleteSolutionById(T id);
	
	@Delete({
		"DELETE FROM solutions \n"
	})
	public void deleteSolutions();
	
	@Select({
		"SELECT COUNT(*) FROM solutions \n"
	})
	public int selectNumSolutions();
}
